<?php 
namespace app\home\model;
use think\Model;

class Member extends Model
{
	public function addm($arr)
	{
		return $this->insert($arr);
	}
	public function checkLogin()
	{
		$con1[]=['username','=',input('username')];
    	$res1=$this->where($con1)->find();
    	if(is_null($res1))
    	{
    		return ['code'=>0,'msg'=>'您输入的用户名错误'];
    	}
		if($res1['password']!=input('pwd'))
		{
			return ['code'=>0,'msg'=>'您输入的密码错误'];
		}
    	session('qid',$res1['id']);
    	session('username',$res1['username']);
    	//var_dump($_SESSION);
    	return ['code'=>1,'msg'=>'登录成功'];
	}

	public function checkold()
	{
		$con1=[['password','=',input('oldpassword')],['id','=',session('qid')]];
		//dump($con1);
		$res1=$this->where($con1)->find();
		if(is_null($res1))
		{
			return ['msg'=>'旧密码错误'];
		}
		if(input('password')!=(input('password_confirm')))
		{
			return ['msg'=>'两次密码输入不一致'];
		}
		return true;
	}
	public function updpwd($arr)
	{
		return $this->where('id',session('qid'))->update($arr);
	}
}